import gnu.io.CommPortIdentifier;

import java.util.Enumeration;

public class CommTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		Enumeration portIdentifiers = CommPortIdentifier.getPortIdentifiers();
		//
//		 Check each identifier if (a) it indicates a serial (not a parallel)
//		 port, and (b) matches the desired name.
		//
		
		while (portIdentifiers.hasMoreElements())
		{
		    CommPortIdentifier pid = (CommPortIdentifier) portIdentifiers.nextElement();
		    if(pid.getPortType() == CommPortIdentifier.PORT_SERIAL) 
		    {
		        System.out.println(pid.getName() + " " + pid.getCurrentOwner());
		    }
		}
			}

}
